package com.emergency.common.util;

import com.emergency.common.entity.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 🙃
 * 🙃 响应工具类
 * 🙃
 * @author:lijie
 * @date :2019/09/06 22:22
 * ResponseUtils.java
 */

public class ResponseUtils {

    private ResponseUtils() {
    }

    /**
     * 设置响应封装
     *
     * @param response HttpServletResponse
     * @param result   result 公共响应类
     * @throws IOException
     */
    public static void setResultResponse(HttpServletResponse response, Result result) throws IOException {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");
        response.getWriter()
                .write(JSONUtils.objToString(result));
    }
}
